﻿using RabbitMQ.Client;

namespace RabbitMQDemo.Common
{
    public static class MQClient
    {
        /// <summary>
        /// 获取RabbitMQ连接
        /// </summary>
        /// <returns></returns>
        public static IConnection GetConnection()
        {
            var factory = new ConnectionFactory
            {
                HostName = "127.0.0.1",
                Port = 5672,
                UserName = "test",
                Password = "test",
                VirtualHost = "/test"
            };

            //var list = new List<AmqpTcpEndpoint>
            //{
            //    new AmqpTcpEndpoint() { HostName = "127.0.0.1", Port = 5672 },
            //    new AmqpTcpEndpoint() { HostName = "127.0.0.1", Port = 5673 },
            //    new AmqpTcpEndpoint() { HostName = "127.0.0.1", Port = 5674 }
            //};

            return factory.CreateConnection();
        }
    }
}
